package com.bao.system.mapper;

import com.bao.system.entity.Entity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author bao
 * @since 2021-06-09
 */
@Repository
public interface EntityMapper extends BaseMapper<Entity> {


    @Select("select e.`id`, `entityname`, `description`, `alias`, `attributes`, `func`, `color`," +
            "e.`strength`, e.`density`, `molecula`, `smell`, `chem_property`, `creattime`, `status`" +
            "from tb_entity e " +
            "${ew.customSqlSegment}")
    IPage<Entity> findEntityPage(Page<Entity> page, @Param(Constants.WRAPPER) QueryWrapper<Entity> wrapper);

    @Delete("delete from tb_entity where tb_entity.id = #{id}")
    void deleEntity(Integer id);

    @Update("update tb_entity e  set e.status = '1' where e.id = #{id} ")
    void examineEntity(Integer id);

    @Insert("INSERT INTO tb_entity (entityname, description, alias, attributes, func, color, strength, density, molecula, smell, chem_property, creattime) values " +
                                "(#{entityname} , #{description}, #{alias}, #{attributes}, #{func}, #{color}, #{strength}, #{density}, #{molecula}, #{smell}, #{chemProperty}, #{creattime})")
    void addEntity(Entity entity);
}
